import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

const path = require('path')

function resolve (dir) {
  return path.join(__dirname, dir)
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve('./src'),
      '@v': resolve('./src/views'),
      '@c': resolve('./src/components'),
      '@u': resolve('./src/utils'),
      '@a': resolve('./src/api'),
    },
  },
  server: {
    port: 1025,
    open: true,
    // 如果端口占用，是退出，还是尝试其他端口
    strictPort: false,
    https: false,
    proxy: {
      '/api': {
        target: 'http://localhost:8080/',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      }
    },
  },

  build: {
    outDir: 'dist'
  }
})

